FROM golang:alpine as builder

WORKDIR /app/server

ENV GO111MODULE=on
ENV CGO_ENABLED=0
ENV GOPROXY=https://goproxy.cn,direct
ENV GOOS=linux
ENV GOARCH=amd64

COPY . .

RUN go mod tidy
RUN go build -o server .

FROM alpine:latest

WORKDIR WORKDIR /app
RUN apk update \
&& apk add tzdata \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone
COPY --from=0 /app/server/server ./
COPY --from=0 /app/server/resource ./resource/
COPY --from=0 /app/server/config.yaml ./

EXPOSE 9501
ENTRYPOINT ./server -c config.yaml